<template>
    <div class="sdy-self"> 
        <sdyHeader title="个人中心" back></sdyHeader>
        <div v-if="handler"  class="box">
            <div class="one">
                <router-link to="/login">
                    <van-button>你还没有登录， 先去登录</van-button>
                </router-link>
            </div>
            <div class="two">
               
                <router-link to="/register">
                    <van-button >没有账号，先去注册 </van-button>
                </router-link>
            </div>
        </div>
        <div v-else class="box1">
            <div>
                个人信息
            </div>

        </div>
    </div>
</template>

<script setup lang="ts">
import { type Router ,useRouter } from 'vue-router'
import { onMounted } from 'vue';

const $router: Router = useRouter()
//登录之后， 应该显示个人信息 ， 
const handler = () =>{

const token = window.localStorage.getItem('token')
const user_id = window.localStorage.getItem('user_id')

    if(!token || !user_id){
        $router.push({path: '/register'})
        return
    }

    $router.push({path: '/message'})
}

  onMounted(() =>{
    handler()
  })


</script>

<style scoped lang="scss">
.sdy-self{
    display: flex;
    height: 100%;
    justify-content: center;
    align-items: center;

    >.box{
        border : 3px solid skyblue;

    
        >.one{
            margin-bottom:30px ;
        }
        >.two{
            display: flex;
            justify-content: center;
            align-items: center;
        }
    }


}

</style>